# -*- coding: utf-8 -*-

from static.extension import db

class IPFS(db.Model):
    __tablename__ = 'ipfs'
    CID  = db.Column(db.String(255), primary_key=True)
    projectCode = db.Column(db.String(255), nullable=False)
    filename = db.Column(db.String(255), nullable=False)
    userid = db.Column(db.Integer, nullable=False)
    username = db.Column(db.String(255), nullable=False)
    version = db.Column(db.String(255), nullable=False)
    upCIDS = db.Column(db.String(255), nullable=False)
    timestamp = db.Column(db.String(255), nullable=False)
    poisonExist = db.Column(db.Integer, default=0,nullable = False)
    poison = db.Column(db.String(255))

    @staticmethod
    def init_db():
        rets = [
            ('Ml82LTfniYfmrrUuYw==', 'QmP65HMPyzUWHgYJAhAMwpzNL4pjhVZBYCE8ty5bRZVFC7', '6-7片段.c', 2, 'xkj','v1.0',0,'null','1717436457.6208544')
        ]
        for ret in rets:
            test = IPFS()
            test.project_code = ret[0]
            test.CID = ret[1]
            test.filename = ret[2]
            test.userid = ret[3]
            test.username = ret[4]
            test.timestamp = ret[5]
            test.poisonExist = ret[6]
            test.poison = ret[7]
            db.session.add(test)
        db.session.commit()


if __name__ == '__main__':
    # 创建数据库表
    db.create_all()

    # 初始化数据
    IPFS.init_db()
